#lang scheme
(#%require r5rs/init)

;(define (mystery x)
;  (define (loop x y)
;    (if (null? x)
;        y
;        (let ((temp (cdr x)))
;          (set-cdr! x y)
;          (loop temp x))))
 ; (loop x '()))

(define mystery
  (lambda (x)
    (define loop
      (lambda (x y)
        (if (null? x)
            y
            ((lambda (temp)
              (set-cdr! x y)
              (loop temp x))
             (cdr x)))))
    (loop x '())))
(write (mystery (list 1 2 3 4)))
